﻿

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PascalConverter
{
    public static class PascalProcessor
    {
        public static void Process()
        {
            FileManager manager = new FileManager();
            manager.rootPath = "";

            var fileNames = manager.GetAllFileNames();
            var files = manager.GetFiles();

            foreach (var fileName in fileNames)
            {
                var pascalName = KeywordManager.ConvertFilenameToPascalCase(fileName.ToString()) + ".asp";
                foreach (var file in files)
                {
                    var fileContents = manager.ReadFile(file);
                    string[] newFileContents = new string[fileContents.Length];
                    for (int i = 0; i < fileContents.Length; i++)
                    {
                        string line = fileContents[i];
                        if (line.ContainsIgnoreCase(pascalName))
                        {
                            newFileContents[i] = line.ReplaceIgnoreCaseAndConvertToPascal(pascalName);
                        }
                        else
                        {
                            newFileContents[i] = line;
                        }
                    }
                    manager.WriteFile(file, newFileContents);
                }
            }
            Console.Read();
        }
    }
}
